import { http } from "@/utils/http";

export interface UploadImageResult {
  code: number;
  data: string; // 返回图片的可访问URL
  message: string;
}

/** 上传图片（头像等） */
export const uploadImage = (file: File) => {
  const form = new FormData();
  // 后端要求字段名为 image
  form.append("image", file);
  return http.request<UploadImageResult>("post", "upload/image", {
    data: form,
    headers: { "Content-Type": "multipart/form-data" }
  });
};
